From 6b0d389bfd8f99857911c22b515de17fa99e68f8 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 8 Oct 2014 13:17:55 +0200 Subject: [PATCH] colorswatch: Draw the image overlay over the whole widget --- gtk/gtkcolorswatch.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/gtk/gtkcolorswatch.c b/gtk/gtkcolorswatch.c index d0feae389a..5f7da4788e 100644 --- a/gtk/gtkcolorswatch.c +++ b/gtk/gtkcolorswatch.c @@ -190,16 +190,16 @@ swatch_draw (GtkWidget *widget, gtk_style_context_restore (context); /* now draw the overlay image */ - gtk_style_context_save (context); - gtk_style_context_add_class (context, GTK_STYLE_CLASS_IMAGE); - gtk_style_context_get_border (context, state, &border); gtk_style_context_get_padding (context, state, &padding); - rect.width = PIXBUF_SIZE + border.left + border.right + padding.left + padding.right; - rect.height = PIXBUF_SIZE + border.top + border.bottom + padding.top + padding.bottom; - rect.x = (width - rect.width) / 2; - rect.y = (height - rect.height) / 2; + rect.width = width - (border.left + border.right + padding.left + padding.right); + rect.height = height - (border.top + border.bottom + padding.top + padding.bottom); + rect.x = border.left + padding.left; + rect.y = border.top + padding.top; + gtk_style_context_save (context); + gtk_style_context_add_class (context, GTK_STYLE_CLASS_IMAGE); + gtk_render_background (context, cr, rect.x, rect.y, rect.width, rect.height); gtk_render_frame (context, cr, rect.x, rect.y, rect.width, rect.height); @@ -213,8 +213,8 @@ swatch_draw (GtkWidget *widget, if (pixbuf != NULL) { gtk_render_icon (context, cr, pixbuf, - rect.x + border.left + padding.left, - rect.y + border.top + padding.top); + rect.x + (rect.width - gdk_pixbuf_get_width (pixbuf)) / 2, + rect.y + (rect.height - gdk_pixbuf_get_height (pixbuf)) / 2); g_object_unref (pixbuf); } -- 2.30.2